﻿/*
**合同详情
*/
Chenxin.UI.ShowDetailContractPage = Chenxin.extend(Chenxin.UI.AddPageCommon,{
    actionUrl:"/service/logic/ShowDetailContract.ashx",
    createForm:function(){
        return new Chenxin.UI.ShowDetailContractForm({
            scope:this
        });
    },
    initEvent:function(){
    }
});
Chenxin.UI.ShowDetailContractForm = Chenxin.extend(Chenxin.UI.AddFormCommon,{
    actionUrl: "/service/logic/ShowDetailContract.ashx",
    id: "divContext",
	saveSucc:function(){
    },
	getInfo:function() {
		_this=this;
		Chenxin.ajax({
			type: "get",
			dataType: "text",
            paramType: 'json',
			async:false,
			url: this.actionUrl,
			data: {op:'getmodel',id:_this.CurrentId},
			onSuccess: function(data) {
				if (data) {
					_this.Model = data.model;
					_this.Info = data.model1;
					_this.LoanInfo3 = data.model3;
					_this.CommisionInfo = data.model4;
					_this.LoanInfo = data.info;
					//办证输入
					_this.CertificateInfo = data.model5;
					//个案补正
					_this.ContractLackItemsInfo = data.model6;
				}
			}	
		});
	},
	initForm:function() {
		_this = this;
		var contractId = Chenxin.Fn.getQueryString("ContractId");
		if(contractId == null || contractId.isBlank()) {
			alert('参数格式错误,加载失败！');
			return ;
		}
		_this.CurrentId = contractId;
		_this.getInfo();
    },
    initEvent: function() {
        $('#baseInfo').click(function() {
			var obj = $('#hidbaseInfo').val();
			if(obj=="show") {
				$('#baseInfo3').show();
				$('#baseInfo1').show();
				$('#baseInfo2').show();
				$('#hidbaseInfo').val("hid");
			}else {
				$('#baseInfo1').hide();
				$('#baseInfo2').hide();
				$('#baseInfo3').hide();
				$('#hidbaseInfo').val("show");
			}
		});
		$('#detailInfo').click(function() {
 			var obj = $('#hidDetailInfo').val();
			if(obj=="show") {
				$('#detailInfo3').show();
				$('#detailInfo2').show();
				$('#detailInfo1').show();
				$('#hidDetailInfo').val("hid");
			}else {
				$('#detailInfo1').hide();
				$('#detailInfo2').hide();
				$('#detailInfo3').hide();
				$('#hidDetailInfo').val("show");
			}
 		});
		$('#payInfo').click(function() {
			var obj = $('#hidPayInfo').val();
			if(obj=="show") {
				$('#payInfo1').show();
				$('#hidPayInfo').val("hid");
			}else {
				$('#payInfo1').hide();
				$('#hidPayInfo').val("show");
			}
		});
    },
    loadDefVal:function(){
		_this = this;
		if(!this.CommisionInfo)
			_this.CommisionInfo="";
		if(!this.LoanInfo3)
			_this.LoanInfo3="";
		if(!this.Info)
			_this.Info="";
		if(!_this.Model.VConsulting) {
			_this.Model.VConsulting = 0;
		}
		if(!_this.CommisionInfo.VConsultingPayed) {
			_this.CommisionInfo.VConsultingPayed = 0;
		}
		if(!_this.Model.VStanCommision) {
			_this.Model.VStanCommision = 0;
		}
		if(!_this.CommisionInfo.VCommisionGeted) {
			_this.CommisionInfo.VCommisionGeted = 0;
		}
		if(!_this.Model.BStanCommision) {
			_this.Model.BStanCommision = 0;
		}
		if(!_this.CommisionInfo.BCommisionGeted) {
			_this.CommisionInfo.BCommisionGeted = 0;
		}
		//成交编号
		$('#ContractCode').html(_this.Model.ContractCode);
		//业绩归
		var dt ="";
		if(_this.Model.ArchivementYear && _this.Model.ArchivementMonth) {
			dt=_this.Model.ArchivementYear+_this.Model.ArchivementMonth;
		}
		$('#ContractYM').html(dt);
		//房屋地址
		$('#HouseAddress').html(_this.Model.HouseAddress);
		//生成时间
		$('#LastCreateArchDate').html(_this.Model.LastCreateArchDate);
		//合同标地
		$('#BargainPrice').html(_this.Model.BargainPrice);
		//买卖合同价
		$('#SalePrice').html(_this.Info.HousePrice);
		//补偿款
		$('#Compensate').html(_this.Info.Compensate);
		//建筑面积
		$('#Area').html(_this.Model.Area);
		//成交日期
		$('#ContractDate').html(_this.Model.ContractDate);
		//签约法务
		$('#lawDepart').html(_this.Model.ContractUserName);
		//最后业绩生成人
		$('#CreateArchEmp').html(_this.Model.CreateArchEmp);
		
		//上家客户
		$('#VenderName').html(_this.Model.VenderName);
		//身份证
		$('#VenderNo').html(_this.Model.VenderNo);
		//上家手机:
		$('#VenderMobile').html(_this.Model.VenderMobile);
		//电话:
		$('#VenderPhone').html(_this.Model.VenderPhone);
		//上家门店:
		$('#VenderDepartName').html(_this.Model.VenderDepartName);
		//业务员:
		$('#VenderUserName').html(_this.Model.VenderUserName);
		//下家客户:
		$('#BuyerName').html(_this.Model.BuyerName);
		//身份证:
		$('#BuyerNo').html(_this.Model.BuyerNo);
		//下家手机:
		$('#BuyerMobile').html(_this.Model.BuyerMobile);
		//电话:
		$('#BuyerPhone').html(_this.Model.BuyerPhone);
		//下家门店:
		$('#BuyerDepartName').html(_this.Model.BuyerDepartName);
		//业务员:
		$('#BuyerUserName').html(_this.Model.BuyerUserName);
		
		//上家佣金:确认
		$('#VStanCommision').html(_this.CommisionInfo.VRealCommisionFinal);
		//实收
		$('#VCommisionGeted').html(_this.CommisionInfo.VCommisionGeted);
		//未收 
		var tem=parseFloat(_this.CommisionInfo.VRealCommisionFinal)-parseFloat(_this.CommisionInfo.VCommisionGeted);
		if(isNaN(tem)) {
			tem=0;
		}
		$('#Vnot').html(tem);
		//折佣 
		$('#VCommision').html(_this.CommisionInfo.VCommisionFinal);
		//约定付款时间
		$('#VConfirmBook').html(_this.Info.VConfirmBook);
		
		//下家佣金:确认
		$('#BStanCommision').html(_this.CommisionInfo.BRealCommisionFinal);
		//实收
		$('#BCommisionGeted').html(_this.CommisionInfo.BCommisionGeted);
		//未收 
		tem = parseFloat(_this.CommisionInfo.BRealCommisionFinal)-parseFloat(_this.CommisionInfo.BCommisionGeted);
		if(isNaN(tem)) {
			tem=0;
		}
		$('#Bnot').html(tem);
		//折佣 
		$('#BCommision').html(_this.CommisionInfo.BCommisionFinal);
		//约定付款时间
		$('#BConfirmBook').html(_this.Info.BConfirmBook);
		//上家咨询费:确认
		$('#VConsulting').html(_this.CommisionInfo.VConsultingFinal);
		//实付
		$('#VConsultingPayed').html(_this.CommisionInfo.VConsultingPayed);
		//未付咨询费 
		tem = parseFloat(_this.CommisionInfo.VConsultingFinal)-parseFloat(_this.CommisionInfo.VConsultingPayed);
		if(isNaN(tem)) {
			tem=0;
		}
		$('#CnotPay').html(tem);
		//下家咨询费:
		$('#BConsulting').html(_this.CommisionInfo.BConsultingFinal);

		//买卖合同价
		$('#SalePrice1').html(_this.Info.HousePrice);
		//建筑面积
		$('#area1').html(_this.Model.Area);
		//单价
		$('#BargainUnitPrice').html(_this.Model.Area/_this.Model.Area);
		//评估价
		$('#price').html(_this.LoanInfo3.EstimatePrice);
		//竣工年份
        $('#compeleYear').html(_this.LoanInfo3.CompleteYear);                 
        //楼层
		var floor="";
		if(_this.Model.CurrentFloor)
		{
			floor =_this.Model.CurrentFloor+"/";
		}
		if(_this.Model.TotalFloor)
		{
			floor =floor+_this.Model.TotalFloor;
		}
        $('#floor').html(floor=="" ? "-/-": floor);        
        //抵押情况
        $('#PawnInfo').html(_this.Info.PawnInfo);                
        //贷款情况
        $('#LoanInfo').html(_this.Info.LoanInfo);                
		//补充条款
		$('#detail0').html(_this.Info.Remark);
		//其他协议
        $('#detail1').html(_this.Info.OtherProtocol);
		//付款方式
		$('#detail2').html(_this.Info.PayStyle);
		//合同约定过户日期
		$('#DealDate').html(_this.Info.DealDate);
		
		$('#personInfo').html(_this.LoanInfo);
		
		//办证输入
		if(_this.CertificateInfo) {
			//发件日期
			$('#SendDate').html(_this.CertificateInfo.SendDate);
			//收件收据日期：
			$('#ReciveDate').html(_this.CertificateInfo.ReciveDate);
			//收件收据编号：
			$('#ReciveCode').html(_this.CertificateInfo.ReciveCode);
			//抵押登记银行：
			$('#Bank').html(_this.CertificateInfo.Bank);
			//抵押登记金额：
			$('#LoanAmount').html(_this.CertificateInfo.LoanAmount);
			//领证情况：
			$('#AccptInfo').html(_this.CertificateInfo.AccptInfo);
			//办证员：
			$('#CertificationPserson').html(_this.CertificateInfo.CertificationPserson);
		}
		//个案补正
		if(_this.ContractLackItemsInfo) {
			$('#txtContractLackItemsInfo').html(_this.ContractLackItemsInfo.LackItems2);
		}
	}
});

getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function() {
    var objPage = new Chenxin.UI.ShowDetailContractPage();
});
